use std::sync::Arc;

use anyhow::Result;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use starrocks_manager::{get, AppConfig};

#[tokio::main]
async fn main() -> Result<()> {
    let config = Arc::new(AppConfig::load().unwrap());
    let password = utf8_percent_encode(&config.db_config.password, NON_ALPHANUMERIC).to_string();
    // #[cfg(feature = "with-mysql")]
    let url = format!(
        "mysql://{}:{}@{}:{}",
        config.db_config.username, password, config.db_config.host, config.db_config.port,
    );

    let pool = mysql_async::Pool::new(url.as_str());
    let mut pool = pool.get_conn().await?;

    get(&config.db_config.dbs, config.clone(), &mut pool).await?;
    Ok(())
}
